package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Map;

@Controller
public class OrderController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping("trade.html")
    public String trade(Model model){
        //  页面需要参数: userAddressList detailArrayList totalNum totalAmount
        Result<Map<String,Object>> result =  orderFeignClient.trade();
        //  Thymeleaf :  页面渲染的数据 ，如果与map 的key 相同，则可以直接映射.
        model.addAllAttributes(result.getData());
        //  返回页面名称.
        return "order/trade";
    }
}

